home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / answrbok / 2_8.lha / 2_8 / 2_8a5.c < prev    next >
Text File  |  1993-08-08  |  781b  |  30 lines

  1. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  2. * The C++ Answer Book */
  3. * Tony Hansen */
  4. * All rights reserved. */
  5. * Copyright (c) 1990 by AT&T Bell Telephone Laboratories, Incorporated. */
  6. * The C++ Answer Book */
  7. * Tony Hansen */
  8. * All rights reserved. */
  9. / <tstbadalign.h>
  10. / this macro will test an assignment
  11. / to an address of each possible offset
  12. / for a given type
  13. define tstbadalignments(type,typestr)        \
  14.    {                        \
  15.    type *ip;                    \
  16.    type ivar;                    \
  17.    int offset;                    \
  18.    cout << "Type = " << typestr << "\n";    \
  19.    for (offset = 0;                \
  20.  offset < sizeof(type);            \
  21.  offset++)                \
  22. {                    \
  23. cout << "\toffset = " << offset;    \
  24. ip = (type *)&foovar.a[offset];        \
  25. if (!setjmp(jmpenv))            \
  26.     ivar = *ip;                \
  27. cout << "\n";                \
  28. }                    \
  29.    }
  30.